home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
SEARCH
/
RUBICON
/
RBVERIFY.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-10-21
|
4KB
|
137 lines
{*********************************************************}
{* RBVERIFY.PAS 1.20 *}
{* Copyright (c) Tamarack Associates 1996. *}
{* All rights reserved. *}
{*********************************************************}
{$B-} {* Boolean evaluation *}
{$G+} {* Generate 286 code *}
{$X+} {* eXtended syntax *}
unit rbVerify;
interface
uses
{$IFDEF WIN32}
Windows,
{$ELSE}
WinTypes, WinProcs,
{$ENDIF}
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, DB, DBTables, ExtCtrls,
taTools, taRubicn;
type
TForm1 = class(TForm)
MakeDictionary1: TMakeDictionary;
WordsDataSource: TDataSource;
DBGrid1: TDBGrid;
Panel1: TPanel;
VerifyBtn: TButton;
RecNoLabel: TLabel;
WordsEdit: TEdit;
WordsTableLabel: TLabel;
WordsTable: TTable;
procedure VerifyBtnClick(Sender: TObject);
procedure WordsEditExit(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
FClosing : BOOLEAN;
FContinue : WORD;
public
{ Public declarations }
PROCEDURE Process;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
PROCEDURE TForm1.Process;
VAR RecNum : LONGINT;
V : TVerifyRecord;
B : TtaBits;
BEGIN
IF NOT WordsTable.Active THEN
RAISE EDictionary.Create('WordsTable not open');
WITH WordsTable DO
BEGIN
RecNum := 0;
FContinue := mrOk;
First;
WHILE NOT EOF AND (FContinue = mrOk) DO
BEGIN
INC(RecNum);
RecNoLabel.Caption := IntToStr(RecNum);
Application.ProcessMessages;
MakeDictionary1.VerifyRecord(V);
B := TtaBits(V.CompressedSize);
{* Compare the count in the record to the bitset *}
IF B.Count <> Fields[wtWordCount].AsInteger THEN
FContinue := MessageDlg('Invalid Count (' + IntToStr(B.Count) + ')',
mtError,[mbOk,mbCancel],0);
{* V.BitCount is the difference between the count in the bitset and *}
{* a recount of the same bitset. Should be zero -- no difference. *}
IF (FContinue = mrOk) AND (V.BitCount <> 0) THEN
FContinue := MessageDlg('Invalid Count (' + IntToStr(V.BitCount) + ')',
mtError,[mbOk,mbCancel],0);
{* V.DecompressedSize is the difference between the ABS(BlobSize) and *}
{* Stream.Size. Should be zero -- no difference. *}
IF (FContinue = mrOk) AND (V.DecompressedSize <> 0) THEN
FContinue := MessageDlg('Invalid Size (' + IntToStr(V.DecompressedSize) + ')',
mtError,[mbOk,mbCancel],0);
{* For compressed blobs, verify FirstSet and LastSet values *}
IF Fields[wtBlobSize].AsInteger > 0 THEN
BEGIN
IF (FContinue = mrOk) AND (V.FirstSet <> B.FirstSet) THEN
FContinue := MessageDlg('Invalid FirstSet',mtError,[mbOk,mbCancel],0);
IF (FContinue = mrOk) AND (V.LastSet <> B.LastSet) THEN
FContinue := MessageDlg('Invalid LastSet',mtError,[mbOk,mbCancel],0);
END;
Next
END
END
END;
procedure TForm1.VerifyBtnClick(Sender: TObject);
begin
WITH Sender AS TButton DO
IF Caption = 'Verify' THEN
TRY
IF NOT WordsTable.Active THEN WordsEditExit(NIL);
Caption := 'Stop';
Process;
FINALLY
Caption := 'Verify'
END
ELSE FContinue := mrCancel
end;
procedure TForm1.WordsEditExit(Sender: TObject);
begin
IF FClosing THEN EXIT;
WITH WordsTable DO
BEGIN
Close;
TableName := AliasToPath(WordsEdit.Text);
Open;
IF NOT CheckStructure(WordsTable) THEN
BEGIN
Close;
RAISE EDictionary.Create('Invalid WordsTable structure')
END
END
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FClosing := TRUE
end;
end.